<%-- 
    Document   : thanhtoan
    Created on : Jun 15, 2013, 1:53:23 AM
    Author     : URUKU
--%>
<%@page import="javax.swing.JOptionPane"%>
<%@page import="java.text.DecimalFormatSymbols"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="java.util.Locale"%>
<%@page import="TrangSuc.Giohang"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="Func.Conn"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
        decimalFormatSymbols.setDecimalSeparator('.');
        decimalFormatSymbols.setGroupingSeparator(',');
        DecimalFormat decimalFormat = new DecimalFormat("#,##0", decimalFormatSymbols);
%>
<%
            String HoTenKH = "";
            String CMNDKH = "";
            String DTKH = "";
            String SoTK = "";
            String Email = "";
            String username = (String)session.getAttribute("USER");
            if(username == null)
            {

            HoTenKH = request.getParameter("HoTenKH");
            CMNDKH = request.getParameter("CMND");
            DTKH = request.getParameter("DT");
            SoTK = request.getParameter("TK");
            Email = request.getParameter("Email");
            }
            else
            {
                try {
                
                    Connection con = Conn.GetCon();
       String sql = "Select * from KhachHang where id = '"+ username +"'";
       //   Statement stm = con.createStatement();
       Statement st = con.createStatement();
       //   stm.setString(1, username);
       // stm.setString(2, password);
       ResultSet rs = st.executeQuery(sql);
       int dt = 0;
       while (rs.next()){  
           
           HoTenKH = rs.getString("Ho") +" "+ rs.getString("TenLot") +" "+ rs.getString("ten");
           CMNDKH = rs.getString("CMND");
           dt = rs.getInt("SDT");
           SoTK = rs.getString("SoTaiKhoan");
           Email = rs.getString("Email");
       }
       DTKH = Integer.toString(dt) ;
       
                }
                catch ( Exception e)
                                               {
                    JOptionPane.showMessageDialog(null, "" + e.getMessage());
                }

                
            }
              
            session.setAttribute("HoTenKH", HoTenKH);
            session.setAttribute("CMNDKH", CMNDKH);
            session.setAttribute("DTKH", DTKH);
            session.setAttribute("SoTK", SoTK);
%>




<!DOCTYPE html>
<html>
   <%@ include file="head.jsp" %>
    <body>
        <div id="divContainer">
    
    <%@ include file="divHeader.jsp" %>
	
    </br>		
    <div class="clr"></div>
				
    <%@ include file="divLeft.jsp" %>
    
	<div id = "divMid">
            <div id ="pro4">
                <center> <h1> Xác Nhận Thông Tin Khách Hàng </h1> </center>
        
                <center> <table width ="40%" border ="1" align ="center">
        
            <tr>
                <td>
                    Họ Tên Khách Hàng : 
                </td>
                <td>
                    <%
                    out.println(""+HoTenKH);
                    %>
                </td>
             </tr>
             <tr>
                <td>
                    Số Chứng Minh Nhân Dân : 
                </td>
                <td>
                    <%
                    out.println(""+CMNDKH);
                    %>
                </td>
            </tr>
            <tr>
                <td>
                    Số Điện Thoại : 
                </td>
                <td>
                    <%
                    out.println(""+DTKH);
                    %>
                </td>
            </tr>
             <tr>
                <td>
                    Số Tài Khoản : 
                </td>
                <td>
                    <%
                    out.println(""+SoTK);
                    %>
                </td>
            </tr>
             <tr>
                <td>
                    Địa Chỉ Email : 
                </td>
                <td>
                    <%
                    out.println(""+Email);
                    %>
                </td>
            </tr>
        
        
        
                    </table></center>
                <br>
    <center><h3> Thông Tin Các Sản Phẩm Đã Mua </h3></center>
     <%
         
           double tongtien=0d;
out.println("<center><table align =\"center\" width=\"70%\" border=\"1\"><tr>"+
"<td> STT </td><td> Tên Sản phẩm </td><td> Số lượng </td>" +
"<td> Đơn giá </td><td> Thành tiền </td>"+
"</tr>"); TrangSuc.Giohang gh=(TrangSuc.Giohang)(session.getAttribute("giohang"));

if(gh!=null){

tongtien=gh.tongtien();
int jj = 0;
for(int i=0;i<=gh.soMonHang()-1;i++){

TrangSuc.Monhang mh=gh.LayMonHang(i);
jj = i + 1;

out.println("<tr><td>"+jj+"</td><td>"+mh.getTen()+"</td><td><input type = 'text'disabled='true' name = 'txtsl' value ='"+

mh.getSoluong()+"'></td><td>"+decimalFormat.format(mh.getGia1donvi())+"</td>"+

"<td>"+decimalFormat.format(mh.getSoluong()*mh.getGia1donvi())+"</td></tr>");

}

out.println("");

out.println("");

}

out.println("</table></center><br><br>");


out.println("<center><h2>Tổng tiền:"+decimalFormat.format(tongtien)+" VND </h2><br><br>");

out.println(""); 
        out.println("<form action ='XuLyThanhToan?TenKH="+HoTenKH+"&SDT="+DTKH+"&CMND="+CMNDKH+"&SoTK="+SoTK+"&TT="+tongtien+"&EMail="+Email+"' method ='post'>");
        out.println("<h3> Nhập Nơi Nhận Sản Phẩm </h3>  ");
        out.println("<input type ='text' name ='NoiNhan'/>");
        out.println("<input type ='submit' name ='btnXacNhan' value ='Next' />");
        out.println("</form>"); 
                %>
                </center></div>
        </div>
       
    <%@ include file="divFooter.jsp" %>  
         </div>

    </body>
</html>